#include "TeaMakerTrayIcon.h"

// Qt Includes
#include <QMenu>
#include <QAction>
#include <QApplication>
#include <QStyle>

// ------------------------------------------------------------
// Construction & Destruction
// ------------------------------------------------------------
CTeaMakerTrayIcon::CTeaMakerTrayIcon(QObject *const parent/* = NULL*/)
	: QSystemTrayIcon(parent)
{
	createContextMenu();
	createSystemTrayIcon();
}

CTeaMakerTrayIcon::~CTeaMakerTrayIcon()
{
	
}

// ------------------------------------------------------------
// Member Functions
// ------------------------------------------------------------
void CTeaMakerTrayIcon::createContextMenu()
{
	m_pMenu = new QMenu;
	ma_pQuit = new QAction(tr("&Quit"), this);
	ma_pConfigure = new QAction(tr("&Configure"), this);

	m_pMenu->addAction(ma_pQuit);
	m_pMenu->addAction(ma_pConfigure);
	
	connect(ma_pQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(ma_pConfigure, SIGNAL(triggered()), this, SIGNAL(configureServer()));
}

void CTeaMakerTrayIcon::createSystemTrayIcon()
{
	if(m_pMenu)
		setContextMenu(m_pMenu);

	setIcon(qApp->style()->standardIcon(QStyle::SP_ArrowUp));
}
